<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="zh-CN">
<html>
  <head>
    <meta charset="utf-8">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge">
  	<%@ include file="/common/sale/include/common-base.jsp"%>
    <title>商品管理-${titleName }</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
  </head>
  <style>
  .nav-tabs-custom > .tab-content{overflow:hidden}
  </style>
  <body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  <!-- top start -->
  <%@include file="/common/bjte/top.jsp" %>
  <!-- top end -->
  
  <!-- left start -->
  <%@include file="/common/bjte/left.jsp" %>
  <!-- left end-->

  <!-- Main start -->
  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
         <!------- 列表 start -------->
	      <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title">还款列表明细 
                 </h3>
                 <div class="box-tools pull-right">
	                 　　　　　　　　<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--列表title  end --> 
              <div class="box-body">
	               <table class="table table-bordered table-hover">
          	<thead class="bg-success">
          		<tr>
          			<th>还款期数</th>
          			<th>还款日期</th>
          			<th>本期应还利息</th>
          			<th>本期应还本金</th>
          			<th>本期应还总额</th>
          			<th>剩余本金</th>
          			<th>还款状态</th>
          			<th>操作</th>
          		</tr>
          	</thead>
          	<tbody>
          		<tr>
          			<td>1</td>
          			<td>2015-08-01</td>
          			<td>426.66</td>
          			<td>0.00</td>
          			<td>426.66</td>
          			<td>50000.00</td>
          			<td>待还款</td>
          			<td>
          				<input type="button" onclick="" class="btn btn-danger" value="还款" />
          			</td>
          		</tr>
          		<tr>
          			<td>2</td>
          			<td>2015-09-01</td>
          			<td>426.66</td>
          			<td>0.00</td>
          			<td>426.66</td>
          			<td>50000.00</td>
          			<td>待还款</td>
          			<td>
          				<input type="button" onclick="" class="btn btn-danger" value="还款" />
          			</td>
          		</tr>
          		<tr>
          			<td>3</td>
          			<td>2015-10-01</td>
          			<td>426.66</td>
          			<td>0.00</td>
          			<td>426.66</td>
          			<td>50000.00</td>
          			<td>待还款</td>
          			<td>
          				<input type="button" onclick="" class="btn btn-danger" value="还款" />
          			</td>
          		</tr>
          		<tr>
          			<td>4</td>
          			<td>2015-11-01</td>
          			<td>426.66</td>
          			<td>0.00</td>
          			<td>426.66</td>
          			<td>50000.00</td>
          			<td>待还款</td>
          			<td>
          				<input type="button" onclick="" class="btn btn-danger" value="还款" />
          			</td>
          		</tr>
          		<tr>
          			<td>5</td>
          			<td>2015-12-01</td>
          			<td>426.66</td>
          			<td>0.00</td>
          			<td>426.66</td>
          			<td>50000.00</td>
          			<td>待还款</td>
          			<td>
          				<input type="button" onclick="" class="btn btn-danger" value="还款" />
          			</td>
          		</tr>
          		<tr>
          			<td>6</td>
          			<td>2016-01-01</td>
          			<td>426.66</td>
          			<td>50000.00</td>
          			<td>50426.66</td>
          			<td>0.00</td>
          			<td>待还款</td>
          			<td>
          				<input type="button" onclick="" class="btn btn-danger" value="还款" />
          			</td>
          		</tr>
          		<tr>
          			<td>总计</td>
          			<td></td>
          			<td>2559.96</td>
          			<td>50000.00</td>
          			<td>52559.96</td>
          			<td></td>
          			<td></td>
          		</tr>
          	</tbody>
          </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
           </div>
	     <!------- 列表 end -------->   
            
            
        
            
           
          </div>
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/bjte/foot.jsp" %>
  <!-- foot start -->
  <!-- right start -->
  <%@include file="/common/bjte/right.jsp" %>
  <!-- right start -->
  
<div win-title="编辑窗口" class="modal fade" id="my_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title"><font color="red">商品-添加/修改</font>&nbsp;</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" role="form" id="submitForm">
					<input type="hidden" name="doCode" value="dymicSql">
					<input type="hidden" name="modelTypes" id="modelTypes" value="i_pubProdInfo">
					<input type="hidden" id="w_infoId" data-name="infoId" name="pubProdInfo.w_infoId"  value="">
					<input name="pubProdInfo.mainStatus"   type="hidden" value="0" />
					<input name="pubProdInfo.expStatus"  type="hidden" value="0" />
					<input name="pubProdInfo.delStatus"   type="hidden" value="F" />
					<input type="hidden" name="formToken" id="formToken" value="">
			        <div class="box-body" id="submitFormData">
			          <!-- Custom Tabs -->
			          <div class="nav-tabs-custom">
			            <div class="tab-content">
			              <div class="tab-pane active" id="tab_1">
			              
			               <div class="col-sm-12">
			                  <label class="col-sm-2 control-label" >商品品种</label>
			                  <div class="col-sm-4">
			                    <div class="form-group">
			                  	 <input type="hidden" id="cateId" name="pubProdInfo.cateId"  value=""/>
			                     <input type="hidden" id="cateNo" name="pubProdInfo.cateNo"  value="" /> 
			                     <input type="hidden" id="cateName" name="pubProdInfo.cateName" value=""/>
			                  	 <select id="selectCate" class="form-control" onchange="changeTo();">
			                  	 </select>
			                  	 </div>
			                  </div>
			                  <label class="col-sm-2 control-label" >商品编号</label>
			                  <div class="col-sm-4">
			                    <div  class="form-group">
			                    <input type="text" id="proNo" name="pubProdInfo.proNo" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="商品编号不能为空！" >
			                    </div>
			                  </div>
			                </div>
			                
			                
			                
			                <div class="col-sm-12">
			                  <label class="col-sm-2 control-label" >商品名称</label>
			                  <div class="col-sm-4">
			                     <div  class="form-group">
				                  <input type="text" name="pubProdInfo.proName" id="proName" class="form-control" data-bv-notempty="true" data-bv-notempty-message="商品名称不能为空！"/>
			                      </div>
			                  </div>
			                  <label class="col-sm-2 control-label" >规格</label>
			                  <div class="col-sm-4">
			                    <div  class="form-group">
			                    <input type="text" id="proSpec" name="pubProdInfo.proSpec" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="规格不能为空！" >
			                    </div>
			                  </div>
			                </div>
			                
			                
			                
			                
			                <div class="col-sm-12">
		                	  <label class="col-sm-2 control-label" >商品简称</label>
			                  <div class="col-sm-4">
			                    <div  class="form-group">
			                    <input type="text" id="proNameShort" name="pubProdInfo.proNameShort" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="商品简称不能为空！" >
			                    </div>
			                  </div>
			                  <label class="col-sm-2 control-label" >等级</label>
			                  <div class="col-sm-4">
			                   <div class="form-group">
			                 	<select id="proLeve" name="pubProdInfo.proLevel" class="form-control" >
			                 		<option>--请选择--</option>
			                 	</select>
			                 	</div>
			                  </div>
			                 </div>
			                 
					         <div class="col-sm-12">
					         	<label class="col-sm-2 control-label" >所在地区</label>
					         	<div class="col-sm-10" id="citySelect">
					         	   <div class="form-group">
							    	<div class="col-sm-3">
										<select class="prov form-control" name="pubProdInfo.province" id="prov" style="margin-left:-15px;width:120px;"></select>
				            		</div>
				            		<div class="col-sm-4">
										<select class="city form-control" name="pubProdInfo.city" id="city" style="margin-left:-22px;width:130px;"></select> 
				            		</div>
				            		</div>
					    	 	</div>
					    	 </div>	 
					    	   
			                  <div class="col-sm-12">
				                  <label class="col-sm-2 control-label" >品牌</label>
				                  <div class="col-sm-4">
				                    <div  class="form-group">
				                    <input type="text" id="proBrand" name="pubProdInfo.proBrand" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="品牌不能为空！"  >
				                    </div>
				                  </div>
				                  <label class="col-sm-2 control-label" >单位</label>
				                  <div class="col-sm-4">
				                   <div class="form-group">
				                  	<select id="proUnit" id="proUnit" name="pubProdInfo.proUnit" class="form-control"></select>
				                   </div>
				                  </div>
			                  </div>
			                  <div class="col-sm-12">
				                  <label class="col-sm-2 control-label" >产地</label>
				                  <div class="col-sm-10">
				                    <div  class="form-group">
				                    <input type="text" id="proPlace" name="pubProdInfo.proPlace" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="产地不能为空！"  >
				                    </div>
				                  </div>
			                  </div>
			                  <div class="col-sm-12">
				                  <label class="col-sm-2 control-label" >商品简介</label>
				                  <div class="col-sm-10">
				                    <div  class="form-group">
				                  	<textarea type="text" class="clean" id="remark" name="pubProdInfo.remark" cols="80" rows="2" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="商品简介能为空！" ></textarea>
				                   </div>
				                  </div>
			                  </div>
			              </div>					             
			              <!-- /.tab-pane -->
			            </div>
			            <!-- /.tab-content -->
			          </div>
			          <!-- nav-tabs-custom -->
			        </div>
	                <div class="box-footer">
		                <button type="button" class="btn btn-success pull-left" onclick="cannel('');">取消</button>
		                <button type="button" class="btn btn-danger pull-right" onclick="submitForm('submitForm');">提 交</button>
		            </div>
				</form>
			</div>
		</div>
		<!-- /.modal-content -->
	</div>		
</div>


</body>
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
			<tr>
				<td><?=strUtil.doNull(rows[i].proNo,'')?></td>
				<td><?=strUtil.doNull(rows[i].proName,'')?></td>
				<td><?=strUtil.doNull(rows[i].proSpec,'')?></td>
				<td><?=strUtil.doNull(rows[i].cateName,'')?></td>
				<td><?=DictUtil.getDictName("qualityLevel",0,rows[i].proLevel)?></td>
				<td><?=strUtil.doNull(rows[i].proNameShort,'')?></td>
				<td>
					<button type="button" class="btn btn-success btn-xs" onclick="toLoad('<?=rows[i].infoId?>','view')">查看</button>&nbsp;&nbsp;
					<button type="button" class="btn btn-warning btn-xs" onclick="toLoad('<?=rows[i].infoId?>','edit');">修改</button>&nbsp;&nbsp;
					 <?if(rows[i].delStatus=='F'){?>
						<button type="button" class="btn btn-danger btn-xs" onclick="delInfo('<?=rows[i].infoId?>');">删除</button>
					 <?}?>
				</td>
			</tr>
		<?}?>
</script>
 <script src="/js/tools-obj.js"></script>
<script src="${ctx}/js/jquery.cityselect-dict.js"></script>
<!-- <script src="${ctx}/js/tools-upload.js"></script> -->
<script>
var clickMenu = "product-list";
var formId = 'submitForm';
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId;
myPage = 6;
dataListId = "dataList";
searchFormId = "searchFrom";
tableSort = "pubProdInfo";
tableId = "infoId";
isShowLog = true;
var infoId = "${param.infoId}";


$(function () {
	//1、加载分页列表数据
	getTableData();
	//2、控制是否启用token
	//setToken();
	$("#citySelect").citySelect({  
	    prov:$("#area_prov").attr("data-val"),
	    city:$("#area_city").attr("data-val"),
	    dist:'',
	    nodata:"none" //当子集无数据时，隐藏select 
	});
	//请在下面补充其他初始化方法（如数据字典、页面加载数据等）
	DictUtil.getDictExtList("#proUnit", dictUrl, {cateEname:"productUnit"});//商品单位
	DictUtil.getDictExtList("#proLeve", dictUrl, {cateEname:"qualityLevel"});
	DictUtil.getDataToSelect("#selectCate",{modelTypes:"s_trpCate"},{value:"cateId",text:"cateName",other:"cateNo,cateType"});
 
	//(id,type,dictUrl,datas,param,defVal)
	
	DictUtil.getSelectCommon("#test-select","dict",dictUrl,{cateEname:"userType"},"","org");//数据字典方式
	DictUtil.getSelectCommon("#test-obj","obj",dictUrl,{modelTypes:"s_trpCate"},{value:"cateId",text:"cateName",other:"cateNo,cateType"},"5902f60fdfe74a6280e9b63036acbc0a");//动态表方式
	
 });
//读取（查询、编辑）数据
 
function toLoad(id,type){
	var paramLoadData = {"pubProdInfo.w_infoId":id,"modelTypes":"s_"+tableSort};
	loadObj(type,paramLoadData);
	setValidate(formId);
}
function delInfo(id){	
	if(confirm("确定要删除信息吗？")){
		$.ajax({
		    type:'post',
		    url:common_submit_url+"?doCode=dymicSql",
		    data:{'pubProdInfo.w_infoId':id,modelTypes:'u_'+tableSort,'pubProdInfo.delStatus':'T'},
		    async:false,
		    dataType:'json',
		    success: function(myData){
		    	if(myData.flag=='T'){
		    		alert("删除成功！");
		    		$('#my_modal').modal('hide');
		    	}else{
		    		alert(myData.msg);
		    	}
		    	getTableData();
		  	}
		});	
	}
}

//反显数据
function showData(type,myData){
	if("view"==type){
		FormUtil.loadView("", myData);
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		FormUtil.fillData("#submitForm", myData,"id");
		$("#modelTypes").val("u_"+tableSort);
		$("#w_"+tableId).val(myData.infoId);
		$("#citySelect").citySelect({
			prov:myData.province,
		    city:myData.city,
		    dist:'',
		    nodata:"" //当子集无数据时，隐藏select 
		});
		var cateName=myData.cateName;			
		$("#selectCate option").each(function(){
			if(this.innerText=cateName){
			$("#selectCate").val(this.value);return false}
		})
	
		DictUtil.checkSelectDict("#proLeve", myData.proLevel);
		$("#my_modal").modal("show");
	}
}

function changeTo(){
// $("#selectCate").find("option:selected").attr("cate-type");
	var cateNo=$("#selectCate").find("option:selected").attr("cate-no");
	var cateId=$("#selectCate").find("option:selected").attr("value");//cateId
	var cateName=$("#selectCate").find("option:selected").text();//cateName
	$("#cateId").val(cateId);
	$("#cateNo").val(cateNo);
	$("#cateName").val(cateName);
}
//清空数据
function cleanDataA(id){
	/**$(':input','#'+id)  
	 .not(':button, :submit, :reset, :hidden, :radio')  
	 .val('')  
	 //.removeAttr('checked')  
	 .removeAttr('selected'); 
	 **/
	$('#'+id).find(".clean").val("");//按照样式清空；
}
/**
 * 表单数据提交
 * @param formId
 */
function submitForm(formId){
	var result;
	$('#'+formId).data('bootstrapValidator').validate();  
	if(!$('#'+formId).data('bootstrapValidator').isValid()){  
	    return ;  
	} 
	 var index_load = layer.load(1, {shade: false});
	  $.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    async:false,
	    dataType:'json',
	    success: function(myData){ 
	    console.log(1111);	
	     console.log(myData);
	     	layer.close(index_load);
		 	layer.alert(myData.msg, {closeBtn: 0,offset: '220px'},
			 	function(){
		      		window.location.href="/sendPage/bjte/admin/product/product-list";
				}
		 	);
		    
	  	},
	     error: function (e) {
		     layer.close(index_load);
     	} 
	});	
	return result;
}

function setValidate(formId){
	$('#'+formId).bootstrapValidator({});
}


</script>
  </body>
</html>





















<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/sale/common-js.jsp"%>
  <%@ include file="/common/sale/common-css.jsp"%>
    <script src="${ctx}/js/jquery.cityselect-dict.js"></script>
  	
  <title>${titleName}</title>
</head>
<body class="hold-transition skin-red sidebar-mini">

<div class="wrapper">
  <!-- top start -->
  <%@include file="/common/product/top-user.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/product/left-user.jsp" %>
  <!-- left end-->
	<div class="content-wrapper">
        <section class="content">
          <div class="row">
          <div class="box box-success">
         	 <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-user"></i> 还款明细列表
                 </h3>
                 <div class="box-tools pull-right">
	                 　　　　　　　　<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
         
	      </div>  
	      </div>  
        </section>
	</div>
</div>
    <!-- foot start -->
  <%@include file="/common/default/foot.jsp" %>
  <!-- foot start -->
  <!-- right start -->
  <%@include file="/common/default/right.jsp" %>
  <!-- right start -->
 </div> 
	</body>
	
	<script type="text/template" id="detailList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
			<tr>
				<td><?=rows[i].diyaName?></td>
				<td>
					<button type="button" class="btn btn-xs btn-primary" onclick="toEdit('<?=rows[i].type?>','<?=rows[i].infoId?>');">修改</button>
						&nbsp;&nbsp;
					<button type="button" class="btn btn-xs btn-danger" onclick="del('<?=rows[i].type?>','<?=rows[i].infoId?>');">删除</button>
				</td>
			</tr>
		<?}?>
</script>
</html>
<script>

var formId='saveForm';
var defaultTab = '#tab_1';
var modalType="i_trpDiya";

var clickMenu= 'project-financing';
var dateObject = $('.date').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
    autoclose: true
});

$(function(){
	setValidate("saveForm");
	
	var diyaId="${param.diyaId}";
	if(diyaId!=null &&diyaId!=""){
		getInfoById(diyaId);
	}else{
		initDiyaId();
	}
});
	

function toAdd(type){
   $("#my_modal_"+type).modal("show");
   var objName="pubDiya"+replaceStr(type)+"Info";
   $("#"+type+"Form").find("[name='modelTypes']").val("i_"+objName);

   FormUtil.cleanDataByClass(type+"Form");
}


function toEdit(type,infoId){
	$("#my_modal_"+type).modal("show");
	loadDetailInfo(infoId,type);
}


function cannel(id){
	$('#'+id).modal('hide');
}

function backhome(){
	window.location.href="${page_admin}/pro/diya/diya-list";
}

function del(type,id){
	if(id =="undefined"){
		alert("请先选中一条数据！");
		return;
	}else{
		var objName="pubDiya"+replaceStr(type)+"Info";
		var conditionCol = objName+".w_infoId";
		$.ajax({ 
			type:'post',
			url:common_submit_url,
			dataType:'json',
		    data:"doCode=dymicSql"+"&modelTypes="+"d_"+objName+"&"+conditionCol+"="+id,
		    success: function(myData){
		    	alert(myData.msg);
	    		var diyaId = $("#saveForm .diyaId").val();

	    		loadDiyaDetail(diyaId);

		  	}
		});	
	}
}


function submitModalForm(formId,modalId,type){
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    dataType:'json',
	    success: function(myData){
	    	//console.log(myData);
	    	if(myData.flag=='T'){
	    		alert("操作成功！");
	    		$("#"+modalId).modal('hide');
	    		
	    		var diyaId = $("#"+formId+" .diyaId").val();
	    		//alert(diyaId);
	    		loadDiyaDetail(diyaId);
	    	}else{
	    		alert(myData.msg);
	    	}
	  	}
	});	
}
function submitForm(formId){
<%--	if(tabId!=null && tabId!="" && tabId!="undefined"){--%>
<%--		$('#'+formId).data('bootstrapValidator').validate();  --%>
<%--		if(!$('#'+formId).data('bootstrapValidator').isValid()){  --%>
<%--		    return ;  --%>
<%--		}  --%>
<%--	}else{--%>
<%--		var proName = $("#dyName").val();--%>
<%--		var proNum = $("#dyPhone").val();--%>
<%--		--%>
<%--		if(proName==null || proName==""){--%>
<%--			layer.alert('单位名称或姓名不能为空!', {--%>
<%--			    closeBtn: 0--%>
<%--			  });--%>
<%--			return ;--%>
<%--		}--%>
<%--		--%>
<%--		if(proNum==null || proNum==""){--%>
<%--			layer.alert('电话号码不能为空！！！',{--%>
<%--			  closeBtn: 0--%>
<%--			});--%>
<%--			return ;--%>
<%--		}--%>
<%--		--%>
<%--		--%>
<%--		--%>
<%--	}--%>
	
	var index_load = layer.load(1, {shade: false});
	$.ajax({
	    type:'post',
	    url:common_submit_url,
	    data:$("#"+formId).serialize(),
	    dataType:'json',
	    success: function(myData){ 
	         //console.log(myData);
		     layer.close(index_load);
	     		layer.alert(myData.msg, {closeBtn: 0,offset: '220px'},
	     				function(){
	     			
	     					if(myData.flag=="T"){
						 		window.location.href="${page_admin}/pro/diya/diya-list";
	     					}
	     				}
	     		);


	  	},
	     error: function (e) {
	    	 //console.log(e);
		     layer.close(index_load);
     	} 
   	 

	});	
}

function setValidate(formId){
}

function getInfoById(id){
	
	//加载抵押主表
	$.ajax({
	    type:'get',
	    url:common_info_url,
	    data:{"trpDiya.w_diyaId":id,"pageName":"nyt-trpDiya-list","formName":"searchForm","doCode":"dymicSql"},
	    async:false,
	    dataType:'json',
	    success: function(myData){
	    	 FormUtil.fillData("#saveForm", myData,"id");
			 $("#formName").val("editForm");
			//加载抵押子表
			loadDiyaDetail(id);
			 $("#citySelect").citySelect({  
				    prov:myData.diyaProvince,
				    city:myData.diyaCity,
				    dist:myData.diyaCountry,
				    nodata:"" //当子集无数据时，隐藏select 
			 });
	  	}
	    
	});
	
	
}



function loadDiyaDetail(diyaId){
	deleteAllRow("detailList");
	if(diyaId==null || diyaId=="" || diyaId=="undefined"){
		diyaId = $("#saveForm .diyaId").val();
	}
	var data=["td","cl","ss","bd","qt"];
	for(i=0;i<data.length;i++){
		var type=data[i];
		
		var objName = "pubDiya"+replaceStr(type)+"Info";
		var conditionCol = objName+".w_diyaId";
		$.ajax({
		    type:'get',
		    url:common_list_url,
		    //data:{"pubDiyaTdInfo.w_diyaId":diyaId,"doCode":"dymicSql","modelTypes":"s_pubDiyaTdInfo"},
		    data:"doCode=dymicSql"+"&modelTypes="+"s_"+objName+"&"+conditionCol+"="+diyaId,
		    async:false,
		    dataType:'json',
		    success: function(myData){
		    	//console.log(myData);
		    	if(myData.total>0){
		    		for(j=0;j<myData.total;j++){
		    			myData.rows[j].type=type;
		    		}
		    		var data = baidu.template("detailList-template",myData);  
					$("#detailList").append(data);
		    	}
		    	
		  	}
		    
		});
	}
	
	
}


function loadDetailInfo(infoId,type){
	var objName = "pubDiya"+replaceStr(type)+"Info";
	var conditionCol = objName+".w_infoId";
	$.ajax({
	    type:'get',
	    url:common_info_url,
	   // data:{"eval(conditionCol)":infoId,"doCode":"dymicSql","modelTypes":"s_"+objName},
	   data:"doCode=dymicSql"+"&modelTypes="+"s_"+objName+"&"+conditionCol+"="+infoId,
	    async:false,
	    dataType:'json',
	    success: function(myData){
	    	console.log(myData);
	    	 FormUtil.fillData("#"+type+"Form", myData,"id");
	    	 $("#"+type+"Form").find("[name='modelTypes']").val("u_"+objName);
	    	 $("#"+type+"Form").find("[name='"+objName+".w_infoId']").val(infoId);
	  	}
	    
	});
}

function initDiyaId(){
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
			 $(".diyaId").val(myData);
	  	}
	});	
}

function deleteAllRow(tableId){
	var tb = document.getElementById(tableId);
	if(tb){
	     var rowNum=tb.rows.length;
	     for (i=0;i<rowNum;i++){
	         tb.deleteRow(i);
	         rowNum=rowNum-1;
	         i=i-1;
	     }
     }
}
</script>



